\fi-960\li960 Q: The rld dynamic loader functions work in a stack oriented manner. How can I use them to load and unload
\fi0\li0 object file
\fi-960\li960 s in a more "random access" manner?\
\fi0\li0 \
\fi-960\li960 A: (This discussion assumes you're running release 2.0.) The stack orientation of the rld functions is intended to ensure that no symbol needed for a particular
\fi0\li0 object file
\fi-960\li960 will ever be needed after it is unloaded. If A, B and C are loaded (in that order), and C needs to reference items in B, B cannot be unloaded without C being first, since it is last-in, first-out.\
\
If your object file sets are independent of each other, that is: C has
\b no
\b0 symbols that it needs from B (in the example above), you may want to load and unload your sets in a more random fashion. If your sets are independent of each other, and you are willing to manage the references yourself, you may use a different strategy. \
Basically, you can use rld_load to load an object file, save away the symbols you need from that object file, and then deallocate the space that this object file consumes when you need to. The steps needed are below:\
\
1) Load the object file you need using
\f0\b\fs32 rld_load().
\f2\b0\fs28 \
2) Use
\f0\b\fs32 rld_lookup()
\f2\b0\fs28 repeatedly to get all of the symbols you need from this object file.\
3) Use
\f0\b\fs32 vm_region()
\f2\b0\fs28 (passing in the address of the mach header, that you got from
\f0\b\fs32 rld_load()
\f2\b0\fs28 ) to find the size of the region you just loaded.\
4) Use
\f0\b\fs32 rld_unload_all()
\f2\b0\fs28 to remove this
\fi0\li0 object file
\fi-960\li960 from rld's data structures. Set deallocate_sets=0 , so that the code will remain in place after rld_unload_all() completes. \
5) When you are done with these routines, you can use
\f0\b\fs32 vm_deallocate()
\f2\b0\fs28 to reclaim the memory. You will need to pass in the size you got from